// API.js => 接口整合文件 => 可以将所有的ajax请求整合到一个文件中 => 方便管理

import {AjaxPromise} from "./ajax.js";

// let baseURL = "http://192.168.53.72";  // 局域网ip
// let baseURL = "http://121.43.116.41"; // 服务器ip

let baseURL = ""; // 同服务器下的后端接口

let token = localStorage.getItem("token") || "";

export const isExistUser = data => AjaxPromise({
    type: "get",
    url: baseURL + "/users/isExistUser",
    data: data,
    async: true,
    dataType: "json",
})

export const isExistPhone = data => AjaxPromise({
    type: "get",
    url: baseURL + "/users/isExistPhone",
    data: data,
    async: true,
    dataType: "json",
})


export const isExistEmail = data => AjaxPromise({
    type: "get",
    url: baseURL + "/users/isExistEmail",
    data: data,
    async: true,
    dataType: "json",
})

export const register = data => AjaxPromise({
    type: "post",
    url: baseURL + "/users/reg",
    data: data,
    async: true,
    dataType: "json",
})

export const login = data => AjaxPromise({
    type: "post",
    url: baseURL + "/users/login",
    data: data,
    async: true,
    dataType: "json",
})

export const searchAllGrade = data => AjaxPromise({
    type: "get",
    url: baseURL + "/grades/all",
    data: data,
    async: true,
    dataType: "json",
})

export const searchGradeOrderLimit = data => AjaxPromise({
    type: "get",
    url: baseURL + "/grades/search",
    data: data,
    async: true,
    dataType: "json",
})

export const searchGradeById = data => AjaxPromise({
    type: "get",
    url: baseURL + "/grades/searchById",
    data: data,
    async: true,
    dataType: "json",
})

export const deleteGradeById = data => AjaxPromise({
    type: "get",
    url: baseURL + "/grades/del",
    data: data,
    async: true,
    headers:{
        token:token,
    },
    dataType: "json",
})

export const updateGradeById = data => AjaxPromise({
    type: "post",
    url: baseURL + "/grades/update",
    data: data,
    async: true,
    headers:{
        token:token,
    },
    dataType: "json",
})



